import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutterApp/api/Api.dart';

class AlarmPage extends StatefulWidget {
  const AlarmPage({Key key}) : super(key: key);

  @override
  _AlarmPageState createState() => _AlarmPageState();
}

class _AlarmPageState extends State<AlarmPage> {
    Map _map = new Map();
  @override
 void initState() {
   // TODO: implement initState
   super.initState();
   this.getData();
 }

 void getData() async {
    //showOkAlertDialog(context:context,title:"登录成功");
    Response response = await getDeviceDetail();
    Map<String, dynamic> data = response.data;
    if (!data['isCorrect']) return; 
    setState(() {
      _map = data['data']['data']['deviceArray'][0];
      print(_map);
    });
  }

  Widget _createPage() {
    return Container(
        child: Stack(overflow: Overflow.visible, children: [
      Positioned(
        child: Image.asset("images/bg-ellipse.png"),
      ),
      Positioned(
        top: 70,
        left: 10,
        right: 10,
        child: Column(children: [
          Container(
            padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
            decoration: BoxDecoration(color: Colors.white,
            borderRadius: BorderRadius.all(Radius.elliptical(5, 5)),
            boxShadow: [
              BoxShadow(
                  color: Colors.grey[200],
                  blurRadius: 2.0,
                  spreadRadius: 2.0),
            ],),
            child: Column(children: [
              Image.asset(
                "images/alarm_icon.png",
                width: 100,
              ),
              SizedBox(height: 10),
              Text(
                "剩余时间",
                style: TextStyle(color: Colors.blue),
              ),
              SizedBox(height: 10),
              Text((_map['sysj'] ?? '')+'Min',
                  style:
                      TextStyle(fontSize: 28.0, fontWeight: FontWeight.w700)),
              SizedBox(height: 20),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/gxsj.png", width: 18),
                            SizedBox(width: 5),
                            Text('更新时间',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text("2021-01-11 16:45:17", style: TextStyle(height: 1.2))
                    ]),
              )
            ]),
          ),
          SizedBox(height: 10),
          Container(
            padding: EdgeInsets.fromLTRB(10, 10, 10, 10),
            decoration: BoxDecoration(color: Colors.white,
            borderRadius: BorderRadius.all(Radius.elliptical(5, 5)),
            boxShadow: [
              BoxShadow(
                  color: Colors.grey[200],
                  blurRadius: 2.0,
                  spreadRadius: 2.0),
            ],),
            child: Column(children: [
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/fmzt.png", width: 18),
                            SizedBox(width: 7),
                            Text('阀门状态',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('正常', style: TextStyle(height: 1.2))
                    ]),
              ),
               Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0,6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/zxzt.png", width: 18),
                            SizedBox(width:7),
                            Text('表号',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('200702006', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/szsj.png", width: 18),
                            SizedBox(width: 7),
                            Text('设置时间',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('0:45Min', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/rqyl.png", width: 18),
                            SizedBox(width: 7),
                            Text('进口压力',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('0Pa', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/rqwd.png", width: 18),
                            SizedBox(width: 7),
                            Text('进口温度',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('0.00', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0,6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/rqls.png", width: 18),
                            SizedBox(width: 7),
                            Text('燃气流速',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('0.03', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/dydy.png", width: 18),
                            SizedBox(width: 7),
                            Text('主电电压',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('5.02V', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/xhqd.png", width: 18),
                            SizedBox(width: 7),
                            Text('信号强度',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('1', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/sbzt.png", width: 18),
                            SizedBox(width:7),
                            Text('基表读数',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('0', style: TextStyle(height: 1.2))
                    ]),
              ),
              Padding(
                padding: EdgeInsets.fromLTRB(0, 6, 0, 6),
                child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: [
                      Row(
                          mainAxisAlignment: MainAxisAlignment.center,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("images/snr.png", width: 18),
                            SizedBox(width: 7),
                            Text('SNR',
                                style:
                                    TextStyle(color: Colors.grey, height: 1.3))
                          ]),
                      Text('-2', style: TextStyle(height: 1.2))
                    ]),
              ),
            ]),
          )
        ]),
      )
    ]));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("报警器详情"),
          centerTitle: true,
          // backgroundColor:Color(0xFF000000)
        ),
        body: SingleChildScrollView(child: this._createPage()));
  }
}
